package Test;
import java.util.ArrayList;

public class AllRoads3 {

    int G_length = 10;
    int[] visit = new int[G_length];

// 定义一个图
    public final static int INFINITY = 0;
    int[][] Graph = {
            {INFINITY,1,1,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
            {1,INFINITY,1,1,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
            {1,1,INFINITY,1,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
            { INFINITY,1,1,INFINITY,1,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY},
            {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,1,INFINITY,INFINITY,INFINITY,INFINITY},
            {INFINITY,INFINITY,INFINITY,INFINITY,1,INFINITY,1,INFINITY,INFINITY,INFINITY},
            {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY	,1,INFINITY,INFINITY},
            {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,1,INFINITY,1,INFINITY},
            {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,1},
            {INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,INFINITY,1,INFINITY}
    };

    ArrayList path = new ArrayList<>();
    ArrayList ans = new ArrayList<String>();

    public void dfs(int start,int end){
        visit[start] = 1;

        path.add((char)((int)'A'+start));

        if(start == end){
            ans.add(path.toString());

        }else{
            for (int i = 0; i < G_length; i++) {
                if(visit[i] == 0 && i != start && Graph[start][i] == 1){
                    dfs(i,end);
                }

            }

        }

        path.remove(path.size()-1);

        visit[start] = 0;
    }

}

